<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://jboss.com/products/seam/taglib"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:rich="http://richfaces.ajax4jsf.org/rich"
                template="layout/template.xhtml">
                       
<ui:define name="body">
    
    <h:messages globalOnly="true" styleClass="message" id="globalMessages"/>
    
    <h:form id="userSearch" styleClass="edit">
    
        <rich:simpleTogglePanel label="User search parameters" switchType="ajax">
        
        
        </rich:simpleTogglePanel>
        
        <div class="actionButtons">
            <h:commandButton id="search" value="Search" action="/UserList.xhtml"/>
        </div>
        
    </h:form>
    
    <rich:panel>
        <f:facet name="header">User search results</f:facet>
    <div class="results" id="userList">

    <h:outputText value="No user exists" 
               rendered="#{empty userList.resultList}"/>
               
    <rich:dataTable id="userList" 
                var="user"
              value="#{userList.resultList}" 
           rendered="#{not empty userList.resultList}">
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="id #{userList.order=='id asc' ? messages.down : ( userList.order=='id desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{userList.order=='id asc' ? 'id desc' : 'id asc'}"/>
                </s:link>
            </f:facet>
            #{user.id}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="username #{userList.order=='username asc' ? messages.down : ( userList.order=='username desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{userList.order=='username asc' ? 'username desc' : 'username asc'}"/>
                </s:link>
            </f:facet>
            #{user.username}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="password #{userList.order=='password asc' ? messages.down : ( userList.order=='password desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{userList.order=='password asc' ? 'password desc' : 'password asc'}"/>
                </s:link>
            </f:facet>
            #{user.password}
        </h:column>
        <h:column>
            <f:facet name="header">
                <s:link styleClass="columnHeader"
                             value="name #{userList.order=='name asc' ? messages.down : ( userList.order=='name desc' ? messages.up : '' )}">
                    <f:param name="order" value="#{userList.order=='name asc' ? 'name desc' : 'name asc'}"/>
                </s:link>
            </f:facet>
            #{user.name}
        </h:column>
        <h:column>
            <f:facet name="header">action</f:facet>
            <s:link view="/#{empty from ? 'User' : from}.xhtml" 
                   value="Select" 
                      id="user">
                <f:param name="userId" 
                        value="#{user.id}"/>
            </s:link>
        </h:column>
    </rich:dataTable>

    </div>
    </rich:panel>
    
    <div class="tableControl">
      
        <s:link view="/UserList.xhtml" 
            rendered="#{userList.previousExists}" 
               value="#{messages.left}#{messages.left} First Page"
                  id="firstPage">
          <f:param name="firstResult" value="0"/>
        </s:link>
        
        <s:link view="/UserList.xhtml" 
            rendered="#{userList.previousExists}" 
               value="#{messages.left} Previous Page"
                  id="previousPage">
            <f:param name="firstResult" 
                    value="#{userList.previousFirstResult}"/>
        </s:link>
        
        <s:link view="/UserList.xhtml" 
            rendered="#{userList.nextExists}" 
               value="Next Page #{messages.right}"
                  id="nextPage">
            <f:param name="firstResult" 
                    value="#{userList.nextFirstResult}"/>
        </s:link>
        
        <s:link view="/UserList.xhtml" 
            rendered="#{userList.nextExists}" 
               value="Last Page #{messages.right}#{messages.right}"
                  id="lastPage">
            <f:param name="firstResult" 
                    value="#{userList.lastFirstResult}"/>
        </s:link>
        
    </div>
    
    <s:div styleClass="actionButtons" rendered="#{empty from}">
        <s:button view="/UserEdit.xhtml"
                    id="create" 
                 value="Create user">
            <f:param name="userId"/>
        </s:button>
    </s:div>
    
</ui:define>

</ui:composition>

